package com.u3k.mid;

import android.util.Base64;
import com.u3k.app.mid.utils.statistics.StatisticsManager;
import java.io.ByteArrayInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;

public class ap {
    public static boolean writeToFile(String[] fileData, String fileName) {
        boolean z = false;
        StringBuilder stringBuilder = new StringBuilder();
        for (String append : fileData) {
            stringBuilder.append(append);
        }
        try {
            byte[] decode = Base64.decode(stringBuilder.toString(), 0);
            FileOutputStream fileOutputStream = new FileOutputStream(fileName);
            InputStream byteArrayInputStream = new ByteArrayInputStream(decode);
            if (byteArrayInputStream != null) {
                decode = new byte[1024];
                while (true) {
                    int read = byteArrayInputStream.read(decode);
                    if (read <= 0) {
                        break;
                    }
                    fileOutputStream.write(decode, 0, read);
                }
                fileOutputStream.close();
                byteArrayInputStream.close();
            }
            z = true;
        } catch (Exception e) {
            e.printStackTrace();
            StatisticsManager.getInstance().logException(ae.a(), e);
        }
        return z ? z : z;
    }
}
